/*
 * CacheEntry.hpp
 *
 *  Created on: 09.12.2012
 *      Author: zheka
 */

#ifndef CACHEENTRY_HPP_
#define CACHEENTRY_HPP_
#include <string>

#include <pthread/ReadWriteLock.hpp>
#include <pthread/Mutex.hpp>
#include "pthread/ILockeble.hpp"
class CacheEntry: public ILockable {
	friend class CacheTask;
private:
	std::string data;
	std::string buffer;
	static const int BUFFER_SIZE;
	size_t size;
	void add(const std::string & s);
	void finish();
	int count;
	bool disposable;
	ReadWriteLock locker;
	Mutex mutex;
public:
	CacheEntry();
	const std::string & getData();
	size_t getSize();
	virtual void lock();
	virtual void unlock();
	void registerTask();
	void unregisterTask();
	int getClientCount();
	bool isDisposable();
};

#endif /* CACHEENTRY_HPP_ */
